Beyoncé Giselle Knowles-Carter is an American singer, songwriter and businesswoman. Dubbed as "Queen Bey" and a prominent cultural figure of the 21st century, she has been recognized for her artistry and performances, with Rolling Stone naming her one of the greatest vocalists of all time.
Robyn Rihanna Fenty is a Barbadian singer, businesswoman, actress, and songwriter. She is widely regarded as one of the most prominent singers of the 21st century.
Shakira Isabel Mebarak Ripoll, known mononymously as Shakira, is a Colombian singer and songwriter. Born and raised in Barranquilla, she has been referred to as the "Queen of Latin Music" and has been praised for her musical versatility.
Ciara Princess Wilson is an American singer, songwriter, businesswoman, dancer, model, and actress. She rose to prominence with her debut studio album Goodies. The album spawned the single of the same name which topped the Billboard Hot 100 and the UK Singles Chart
Megan Jovon Ruth Pete, known professionally as Megan Thee Stallion, is an American rapper. Originally from Houston, Texas, she first garnered attention when videos of her freestyling became popular on social media platforms such as Instagram
Jennifer Lynn Affleck, known by her maiden name and also shortened to J.Lo, is an American singer and actress. Often considered a pop culture icon, Lopez is one of the most influential entertainers in the world, credited for helping propel the Latin pop movement in American music.
# lets import libraries
from googleapiclient.discovery import build
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Function to get Beyonce Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Beyonce_channel_id = ['UCuHzBCaKmtaLcRAOoazhCPA' # Beyonce
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Beyonce_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Beyonce_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,Beyonce_channel_id)
[{'Channel_name': 'Beyoncé', 'Subscribers': '26600000', 'Views': '18021652519', 'Total_videos': '245'}]
channel_statistics = get_channel_stats(youtube,Beyonce_channel_id )
Beyonce_channel_data =pd.DataFrame(channel_statistics)
Beyonce_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Beyoncé | 26600000 | 18021652519 | 245 |
# Function to get Rihanna in Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Rihanna_channel_id = ['UCcgqSM4YEo5vVQpqwN-MaNw' # Rihanna
]
youtube = build('youtube','v3',developerKey = api_key)
def get_channel_stats(youtube, Rihanna_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Rihanna_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,Rihanna_channel_id)
[{'Channel_name': 'Rihanna', 'Subscribers': '42600000', 'Views': '23606574806', 'Total_videos': '85'}]
channel_statistics = get_channel_stats(youtube,Rihanna_channel_id )
Rihanna_channel_data =pd.DataFrame(channel_statistics)
Rihanna_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Rihanna | 42600000 | 23606574806 | 85 |
# Function to get Shakira Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Shakira_channel_id = ['UCYLNGLIzMhRTi6ZOLjAPSmw' # Shakira
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Shakira_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Shakira_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,Shakira_channel_id )
[{'Channel_name': 'Shakira', 'Subscribers': '45400000', 'Views': '29153079577', 'Total_videos': '342'}]
channel_statistics = get_channel_stats(youtube,Shakira_channel_id )
Shakira_channel_data =pd.DataFrame(channel_statistics)
Shakira_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Shakira | 45400000 | 29153079577 | 342 |
# Function to get Ciara Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Ciara_channel_id = ['UClc5Eis2-L2JCcN62jmD21w' # Ciara
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Ciara_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Ciara_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,Ciara_channel_id)
[{'Channel_name': 'Ciara', 'Subscribers': '5760000', 'Views': '3594425762', 'Total_videos': '217'}]
channel_statistics = get_channel_stats(youtube,Ciara_channel_id)
Ciara_channel_data =pd.DataFrame(channel_statistics)
Ciara_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Ciara | 5760000 | 3594425762 | 217 |
# Function to get Megan Stallion Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Megan_Stallion_channel_id = ['UCKrdjiuS66yXOdEZ_cOD_TA' # Megan Stallion
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Megan_Stallion_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Megan_Stallion_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,Megan_Stallion_channel_id)
[{'Channel_name': 'Megan Thee Stallion', 'Subscribers': '5860000', 'Views': '2640609521', 'Total_videos': '245'}]
channel_statistics = get_channel_stats(youtube,Megan_Stallion_channel_id )
Megan_Stallion_channel_data =pd.DataFrame(channel_statistics)
Megan_Stallion_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Megan Thee Stallion | 5860000 | 2640609521 | 245 |
# Function to get Jeniffer Lopez Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Jeniffer_Lopez_channel_id = ['UCr8RjWUQ_9KYcIPmWiqBroQ' # Jeniffer Lopez
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Jeniffer_Lopez_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Jeniffer_Lopez_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,Jeniffer_Lopez_channel_id)
[{'Channel_name': 'Jennifer Lopez', 'Subscribers': '16500000', 'Views': '10579401741', 'Total_videos': '301'}]
channel_statistics = get_channel_stats(youtube,Jeniffer_Lopez_channel_id )
Jeniffer_Lopez_channel_data =pd.DataFrame(channel_statistics)
Jeniffer_Lopez_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Jennifer Lopez | 16500000 | 10579401741 | 301 |
# Combine DataFrames using concat
combined_female_pop_artist_channels_df = pd.concat([
Beyonce_channel_data,
Rihanna_channel_data ,
Shakira_channel_data,
Ciara_channel_data,
Megan_Stallion_channel_data,
Jeniffer_Lopez_channel_data,
], ignore_index=True)
# Display the result
print(combined_female_pop_artist_channels_df)
Channel_name Subscribers Views Total_videos 0 Beyoncé 26600000 18021652519 245 1 Rihanna 42600000 23606574806 85 2 Shakira 45400000 29153079577 342 3 Ciara 5760000 3594425762 217 4 Megan Thee Stallion 5860000 2640609521 245 5 Jennifer Lopez 16500000 10579401741 301
combined_female_pop_artist_channels_df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 6 entries, 0 to 5 Data columns (total 4 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Channel_name 6 non-null object 1 Subscribers 6 non-null object 2 Views 6 non-null object 3 Total_videos 6 non-null object dtypes: object(4) memory usage: 324.0+ bytes
combined_female_pop_artist_channels_df['Subscribers'] = pd.to_numeric(combined_female_pop_artist_channels_df['Subscribers'])
combined_female_pop_artist_channels_df['Views'] = pd.to_numeric(combined_female_pop_artist_channels_df['Views'])
combined_female_pop_artist_channels_df['Total_videos'] = pd.to_numeric(combined_female_pop_artist_channels_df['Total_videos'])
combined_female_pop_artist_channels_df.info
<bound method DataFrame.info of Channel_name Subscribers Views Total_videos 0 Beyoncé 26600000 18021652519 245 1 Rihanna 42600000 23606574806 85 2 Shakira 45400000 29153079577 342 3 Ciara 5760000 3594425762 217 4 Megan Thee Stallion 5860000 2640609521 245 5 Jennifer Lopez 16500000 10579401741 301>
import matplotlib.pyplot as plt
# Sort the DataFrame by 'Subscribers' in descending order
combined_female_pop_artist_channels_df_subscribers_sorted = combined_female_pop_artist_channels_df.sort_values(by='Subscribers', ascending=False)
# Plotting Subscribers in descending order
fig, axes = plt.subplots(nrows=3, ncols=1, figsize=(10, 15))
axes[0].bar(combined_female_pop_artist_channels_df_subscribers_sorted['Channel_name'],combined_female_pop_artist_channels_df_subscribers_sorted['Subscribers'], color='blue')
axes[0].set_title('Subscribers', fontsize=20) # Adjust title font size as needed
# Sort the DataFrame by 'Views' in descending order
combined_female_pop_artist_channels_df_views_sorted = combined_female_pop_artist_channels_df.sort_values(by='Views', ascending=False)
# Plotting Views in descending order
axes[1].bar(combined_female_pop_artist_channels_df_views_sorted['Channel_name'], combined_female_pop_artist_channels_df_views_sorted['Views'], color='green')
axes[1].set_title('Views', fontsize=20) # Adjust title font size as needed
# Sort the DataFrame by 'Total_videos' in descending ordercombined_female_pop_artist_channels_df
combined_female_pop_artist_channels_df_total_videos_sorted = combined_female_pop_artist_channels_df.sort_values(by='Total_videos', ascending=False)
# Plotting Total Videos in descending ordercombined_male_rnb_artist_channels_df
axes[2].bar(combined_female_pop_artist_channels_df_total_videos_sorted['Channel_name'], combined_female_pop_artist_channels_df_total_videos_sorted['Total_videos'], color='orange')
axes[2].set_title('Total Videos', fontsize=20) # Adjust title font size as needed
# Adjust layout for better visibility
plt.tight_layout()
# Show the plot
plt.show()